from django.db import models

# Create your models here.
class User(models.Model):
    name = models.CharField(max_length=50, verbose_name='用户名', blank=False, null=False)
    mobile = models.CharField(max_length=20, verbose_name='手机号', blank=False, null=False)
    password = models.CharField(max_length=255, verbose_name='密码', blank=False, null=False)
    email = models.CharField(max_length=100, verbose_name='邮箱', blank=True, null=True)
    pic_url = models.CharField(max_length=255, verbose_name='头像', blank=True, null=True)
    totalscore = models.IntegerField(default=0, verbose_name='总积分')
    uid = models.CharField(max_length=500,blank=True, null=True,default="12")

    class Meta:
        verbose_name = '用户'
        verbose_name_plural = '用户'

    def __str__(self):
        return self.name

class ThirdLogin(models.Model):
    LOGIN_TYPE_CHOICES = [
        (1, '钉钉'),
        (2, '微信'),
        (3, 'QQ'),
        (4, '微博'),
    ]
    token=models.CharField(max_length=500,verbose_name='刷新token')
    user = models.ForeignKey(User, on_delete=models.CASCADE, verbose_name='用户ID', null=True, blank=True)
    login_type = models.IntegerField(verbose_name='登录类型',choices=LOGIN_TYPE_CHOICES)
    uid = models.CharField(max_length=100, verbose_name='用户唯一标识')


    class Meta:
        verbose_name = '第三方登录'
        verbose_name_plural = '第三方登录'

    def __str__(self):
        return f"{self.login_type} - {self.uid}"